import type { AddressItem, MedicalOrderDetail, MedicineOrderDetail } from '@/types/medicineOrder'
import { request } from '@/utils/request'

// 获取收货地址列表
export const getAddressListApi = () => {
  return request.get<null, AddressItem[]>('/patient/order/address')
}

// 获取药品预付订单详情
export const getMedicineOrderDetailApi = (prescriptionId: string) => {
  return request.get<null, MedicineOrderDetail>(`/patient/medicine/order/pre`, {
    params: {
      prescriptionId,
    },
  })
}

/**
 * 药品待支付订单
 */
export const createOrderApi = (id: string, addressId: string) => {
  return request.post<any, { id: string }>('/patient/medicine/order', { id, addressId })
}

/**
 * 获取药品订单详情
 * @param id 订单id
 * @returns
 */
export const getMedicalOrderDetail = (id: string) =>
  request.get<any, MedicalOrderDetail>(`/patient/medicine/order/detail/${id}`)

/**
 * 药品订单列表
 */
export const orderListApi = (status = 10, current = 1, pageSize = 10) => {
  return request.get<any, any>('/patient/medicine/order/mylist', {
    params: { status, current, pageSize },
  })
}
